package com.qidianit.mes.pro.controller;


import com.qidianit.mes.common.Result;
import com.qidianit.mes.pojo.pro.WorkFlowProduct;
import com.qidianit.mes.pro.service.WorkFlowProductService;
import lombok.experimental.Delegate;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * Package Path: com.qidianit.mes.pro.controller
 * Author: Alhz
 * Description:
 * Date: 2025/9/18 16:43
 */
@RestController
@RequestMapping("/workflowProduct")
public class WorkFlowProductController {
    @Autowired
    private WorkFlowProductService workFlowProductService;

    /**
     * 查询工艺流程产品关联列表
     * @param workFlowid
     * @param page
     * @param pageSize
     * @return
     */
    
    @GetMapping("/page")
    public Result selectWorkFlowProductPage(@RequestParam("workflowId") Long workFlowid , @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int pageSize){
        return workFlowProductService.selectWorkFlowProductPage(workFlowid, page, pageSize);
    }

    /**
     * 新增工艺流程产品关联
     * @param workFlowProduct
     * @return
     */
    @PostMapping("/add")
    public Result addWorkFlowProduct(@RequestBody WorkFlowProduct workFlowProduct){
        return workFlowProductService.addWorkFlowProduct(workFlowProduct);
    }

    /**
     * 根据id获取对应的信息
     * @param id
     * @return
     */

    @GetMapping("/{id}")
    public Result selectWorkFlowProductById(@PathVariable Long id){
        return  workFlowProductService.getWorkFlowProductById(id);
    }


    /**
     * 更新工艺流程产品关联
     * @param workFlowProduct
     * @return
     */
    @PutMapping("/update")
    public Result updateWorkFlowProduct(@RequestBody WorkFlowProduct workFlowProduct){
        return workFlowProductService.updateWorkFlowProduct(workFlowProduct);
    }

    /**
     * 根据id删除工艺流程产品关联
     * @param id
     * @return
     */
    @DeleteMapping("/delete/{id}")
    public Result deleteWorkFlowProductById(@PathVariable Long id){
        return workFlowProductService.deleteWorkFlowProductById(id);
    }

    /**
     * 批量删除工艺流程产品关联
     * @param ids
     * @return
     */
    @DeleteMapping("/batchDelete")
    public Result batchDeleteWorkFlowProduct(Long[] ids){
        return workFlowProductService.batchDeleteWorkFlowProduct(ids);
    }
}